package edu.towson.cosc.cosc455.kchmura.compiler;

import java.io.IOException;

/**
 * 
 * @author kchmur1
 * This class converts the input into html.
 */
public class MySemanticAnalyzer {
    
	String html = "<html>";
	String htmlEnd = "</html>"; 
	String comment = "<comment>";
	String commentEnd = "</comment>"; 
	String head = "<head>";
	String headEnd = "</head>"; 
	String title = "<title>";
	String titleEnd = "</title>"; 
	String paragraph = "<p>";
	String paragraphEnd = "</p>"; 
	String bold = "<b>";
	String boldEnd = "</b>"; 
	String italics = "<i>";
	String italicsEnd = "</i>"; 
	String list = "<ul>";
	String listEnd = "</ul>"; 
	String item = "<li>";
	String itemEnd = "</li>"; 
	String newline = "<br>";
	String soundStart = "<audio controls";
	String soundEnd	= "</audio>";
	String videoStart = "<iframe src =";
	String videoEnd = "/>";
	
        /**
         * This checks/converts the lolcode tokens to html code and writes the html to the previously created output file.
         * @throws IOException
         */
        public void semanticConverter() throws IOException{
	
		if(compiler.token.equalsIgnoreCase(LexicalTokens.DOC_BEGIN)){
			compiler.outputArrayMethod(html);
		}
		else if(compiler.token.equalsIgnoreCase(LexicalTokens.DOC_END)){
			compiler.outputArrayMethod(htmlEnd);
		}
		else if(compiler.token.equalsIgnoreCase(LexicalTokens.COMMENT_BEGIN)){
			compiler.outputArrayMethod(comment);
		}
		else if(compiler.token.equalsIgnoreCase(LexicalTokens.COMMENT_END)){
			compiler.outputArrayMethod(commentEnd);
		}
		else if(compiler.token.equalsIgnoreCase(LexicalTokens.HEAD_BEGIN)){
			compiler.outputArrayMethod(head);
		}	
		else if(compiler.token.equalsIgnoreCase(LexicalTokens.HEAD_END)){
			compiler.outputArrayMethod(headEnd);
		}
		else if(compiler.token.equalsIgnoreCase(LexicalTokens.TITLE_BEGIN)){
			compiler.outputArrayMethod(title);
		}
		else if(compiler.token.equalsIgnoreCase(LexicalTokens.TITLE_END)){
			compiler.outputArrayMethod(titleEnd);
		}
		else if(compiler.token.equalsIgnoreCase(LexicalTokens.PARAGRAPH_BEGIN)){
			compiler.outputArrayMethod(paragraph);
		}
		else if(compiler.token.equalsIgnoreCase(LexicalTokens.PARAGRAPH_END)){
			compiler.outputArrayMethod(paragraphEnd);
		}
		else if(compiler.token.equalsIgnoreCase(LexicalTokens.BOLD_BEGIN)){
			compiler.outputArrayMethod(bold);
		}
		else if(compiler.token.equalsIgnoreCase(LexicalTokens.BOLD_END)){
			compiler.outputArrayMethod(boldEnd);
		}
		else if(compiler.token.equalsIgnoreCase(LexicalTokens.ITALICS_BEGIN)){
			compiler.outputArrayMethod(italics);
		}
		else if(compiler.token.equalsIgnoreCase(LexicalTokens.ITALICS_END)){
			compiler.outputArrayMethod(italicsEnd);
		}
		else if(compiler.token.equalsIgnoreCase(LexicalTokens.LIST_BEGIN)){
			compiler.outputArrayMethod(list);
		}
		else if(compiler.token.equalsIgnoreCase(LexicalTokens.LIST_END)){
			compiler.outputArrayMethod(listEnd);
		}
		else if(compiler.token.equalsIgnoreCase(LexicalTokens.ITEM_BEGIN)){
			compiler.outputArrayMethod(item);
		}
		else if(compiler.token.equalsIgnoreCase(LexicalTokens.ITEM_END)){
			compiler.outputArrayMethod(itemEnd);
		}
		else if(compiler.token.equalsIgnoreCase(LexicalTokens.NEWLINE)){
			compiler.outputArrayMethod(newline); 
		}
		else if(compiler.token.equalsIgnoreCase(LexicalTokens.SOUNDS_BEGIN)){
			compiler.outputArrayMethod(soundStart);
		}
		else if(compiler.token.equalsIgnoreCase(LexicalTokens.SOUNDS_END)){
			compiler.outputArrayMethod(soundEnd);
		}
		else if(compiler.token.equalsIgnoreCase(LexicalTokens.VIDEO_BEGIN)){
			compiler.outputArrayMethod(videoStart);
		}
		else if(compiler.token.equalsIgnoreCase(LexicalTokens.VIDEO_END)){
			compiler.outputArrayMethod(videoEnd);
		}
		
		
	}
}
